<?php

class PhpFox_Mod_Video_ComponentModifyCategories extends BaseComponent
{
    function process()
    {
    	$oReq = &App::getRequest();

    	if ( $iEdit = $oReq->get('edit') )
    	{
    		$this->oDatabase->update(App::getT('videos_list'), array('list_name' => $oReq->get('text')), "list_id = '". $iEdit ."'");
    		App::gotoUrl('admin.sections.video-categories', array(), App::format('Mod_Video.category_updated'), false);
    	}

		if ( $sName = $oReq->get('name') )
		{
			$this->oDatabase->insert(App::getT('videos_list'), array('list_name' => $sName));
			App::gotoUrl('admin.sections.video-categories', array(), App::format('Mod_Video.category_added'), false);
		}

    	if ( $iDelete = $oReq->get('idelete') )
    	{
    		$this->oDatabase->_delete(App::getT('videos_list'), "list_id = '". $iDelete ."'");
    		App::gotoUrl('admin.sections.video-categories', array(), App::format('Mod_Video.category_deleted'), false);
    	}

		$aItems = $this->oDatabase->getRows("SELECT list_name, list_total, list_id FROM ". App::getT('videos_list') ." ORDER BY list_name ASC");

		$this->oTpl->assign(array
		(
			'aItems' => $aItems,
		));

		return $this->oTpl->fetch('ModifyCategories.html');
    }
}

?>